package com.hsp.Demo_03_object;

public class Demo_14 {
    public static void main(String[] args) {
        /*
         3、编写类Book,定义方法updatePrice，实现更改某本书的价格，具体：如果价格>150,则更改为150，
           如果价格>100,则更改为100，否则不变。
         */
        Book book = new Book("时间简史", 101.0);
        book.updatePrice(book);
        System.out.println(book.name + "最后的售价为：" + book.price);
    }
}

class Book{
    String name;
    double price;

    public Book(String name, double price){
        this.name = name;
        this.price = price;
    }

    public void updatePrice(Book book){
        if(book.price > 150){
            book.price = 150.0;
        }else if(book.price > 100){
            book.price = 100.0;
        }
    }

}